/**
 *
 */
package org.text2diagram.nlp.opennlp;

import java.io.IOException;

import opennlp.tools.lang.english.ParserTagger;

import org.text2diagram.nlp.core.NLPDetector;
import org.text2diagram.nlp.core.NLPException;

/**
 * @author alex
 *
 */
public class OpenNLPPosTagDetector implements NLPDetector<String[], String[]> {
   /**
     * English POS tag detector.
     */
    private static ParserTagger tagger;
    /**
     * Instance of English OpenNLP POS tag detector.
     */
    private static OpenNLPPosTagDetector instance = new OpenNLPPosTagDetector();

    /**
     * Disable default constructor.
     */
    private OpenNLPPosTagDetector() {
        super();
        try {
			tagger = new ParserTagger(
					"resources/models/opennlp/english/postag/tag.bin.gz",
			    	"resources/models/opennlp/english/postag/tagdict",
			    	false);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

    /**
     * Get default instance of English OpenNLP POS tag detector.
     * @return default instance of English OpenNLP POS tag detector.
     */
    public static OpenNLPPosTagDetector getInstance() {
        return instance;
    }

	@Override
	public String[] detect(String[] data) throws NLPException {
		return tagger.tag(data);
	}

}
